package org.liuwei.concucrent.base12.CopyOnWriteArrayList;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
/**
 * 
 * @类名: Resource3.java
 * @包名 org.liuwei.concucrent.CopyOnWriteArrayList
 * @描述: TODO
 * Copyright: Copyright (c) 2016 
 * 
 * @开发者 刘伟
 * @日期 2016年8月19日 下午4:19:17
 * @version V1.0.0
 */
public class Right {

	public static void main(String[] args) throws InterruptedException {
		List<String> a = new ArrayList<String>();
		a.add("刘");
		a.add("伟");
		a.add("伟");
		final CopyOnWriteArrayList<String> list = new CopyOnWriteArrayList<String>(
				a);
		Thread t = new Thread(new Runnable() {
			int count = -1;

			public void run() {
				while (true) {
					list.add(count++ + "");
				}
			}
		});
		t.setDaemon(true);
		t.start();
		Thread.currentThread().sleep(3);
		for (String s : list) {
			System.out.println(list.hashCode());
			System.out.println(s);
		}
	}
}
